//
//  HunterTableViewCell.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/25.
//  Copyright © 2016年 light. All rights reserved.
//

#import "HunterTableViewCell.h"
#import "Hunter_listModel.h"
#import "HunterCollectionViewCell.h"
@interface HunterTableViewCell () <UICollectionViewDataSource, UICollectionViewDelegate>

@end

@implementation HunterTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCollectionView];
        
    }
    return self;
}

- (void)createCollectionView
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 4 / 5, 200);
    flowLayout.sectionInset = UIEdgeInsetsMake(5, 10, 5, 10);
    flowLayout.minimumInteritemSpacing = 10;
    flowLayout.minimumLineSpacing = 10;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 210) collectionViewLayout:flowLayout];
    self.collectionV.delegate = self;
    self.collectionV.dataSource = self;
    self.collectionV.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.collectionV];
    [self.collectionV registerClass:[HunterCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.collectionV.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 210);
    
    
}

- (NSInteger )collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.array.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    HunterCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    Hunter_listModel *model = [self.array objectAtIndex:indexPath.row];
    cell.model = model;
    cell.backgroundColor = [UIColor colorWithRed:251 / 255.0  green:248 / 255.0 blue:241 / 255.0 alpha:1];
    
    return cell;
}



@end
